extern crate serde;
extern crate serde_json;

use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug)]
pub struct OrderUpdateRequest {
    pub action:String,
    pub order_id:String,
    pub user_id:i64,
    pub side:String,
    pub order_type:String,
    pub base_asset:String,
    pub quote_asset:String,
    pub price:f64,
    pub quantity:f64,
    pub original_quantity:f64,
    pub order_time:i64,
    pub version:i32,
    pub via:String,
    pub symbol:String,
    // execType:String,
    pub pass_time_seconds:i64,//取消订单超时时间.如果订单已经超时,则取消该订单.只有在取消订单中生效.
    pub is_batch_order_end:bool,
}


/**
* 订单的买卖方向.
*/
#[derive(Serialize, Deserialize, Debug)]
pub enum OderSide {
    SideSell(String),
    SideBuy(String)
}

/**
* 订单类型.
*/
#[derive(Serialize, Deserialize, Debug)]
pub enum OrderType {
    Market(String),
    Limit(String)
}

/**
* 订单类型.
*/
#[derive(Serialize, Deserialize, Debug)]
pub enum Action {
    Action_Create(String),
    Action_Cancel(String),
    ACTION_CANCEL_OVERTIME_ROBOT(String),
    ACTION_GEN_RESULT_ROBOT(String),
    ACTION_ACTIVE_ROBOT(String),
    ACTION_REMATCH(String),
}

pub mod common;

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_display() {
        let n = OrderUpdateRequest{
            action:"place".to_string(),
            order_id:"123456".to_string(),
            user_id:10000,
            side:"buy".to_string(),
            order_type:"limit".to_string(),
            base_asset:"BTC".to_string(),
            quote_asset:"USDT".to_string(),
            price:10000.0,
            quantity:2.0,
            original_quantity:2.0,
            order_time: 546544221544,
            version: 0,
            via: "".to_string(),
            symbol: "BTC_USDT".to_string(),
            pass_time_seconds: -1,
            is_batch_order_end: false,
        };
        println!("{:#?}",n);
    }

}